package com.foreknow.Test;


import java.util.ArrayList;
import java.util.List;

public class Example1 {
    public static void main(String[] args) {
        List<Student> list =new ArrayList<>();
        Student student1 = new Student("fender",12,99);
        Student student2 = new Student("张三",12,99);
        Student student3 = new Student("张四",12,90);
        Student student4 = new Student("王五",12,95);
        Student student5 = new Student("李四",12,100);
        list.add(student1);
        list.add(student2);
        list.add(student3);
        list.add(student4);
        list.add(student5);
        double sorce = 0;
        int people = 0;
        for (Student student:list){
            String name = student.getName();
            String zhang = name.substring(0,1);
            if (zhang.equals("张")){
                sorce += student.getSorce();
                people++;
            }
        }
        sorce = sorce / people;
        System.out.println(sorce);
    }
}
